package com.webdrop.client;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;


/**
* This class enables the user to get String responses by HTTP request.
* @author Sean
*
*/
public class HttpRequest implements RequestCallback{

   /**
    * Constructor for a simple Http Request
    * @param url The URL to call
    */
   public HttpRequest(String url) {
      RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,url);
      builder.setCallback(this);
      try {
         builder.send();
      }
      catch(Exception e) {
         e.printStackTrace();
      }
   }

   /**
    * If things fail this is called
    */
   public void onError(Request request, Throwable exception) {
      Window.alert("An error occurred: " + exception.getMessage()); 
   }

   /**
    * If things go well, this is called
    */
   public void onResponseReceived(Request request, Response response) 
   {
   
   }
   
   
}